define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'admin/platformBoxPrize/index?platform_box_id=' + window.platformBoxId,
        add_url: 'admin/platformBoxPrize/add?platform_box_id=' + window.platformBoxId,
        edit_url: 'admin/platformBoxPrize/edit?platform_box_id=' + window.platformBoxId,
        delete_url: 'admin/platformBoxPrize/delete?platform_box_id=' + window.platformBoxId,
        export_url: 'admin/platformBoxPrize/export?platform_box_id=' + window.platformBoxId,
        modify_url: 'admin/platformBoxPrize/modify?platform_box_id=' + window.platformBoxId,
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'add'],
                cols: [[
                    {field: 'type', title: '类型', search: 'select', selectList: {1: '实物', 2: '红包'}, templet: function (d) {
                        if (d.type === 1) {
                            return '实物';
                        } else if (d.type === 2) {
                            return '红包';
                        }
                    }},
                    {field: 'name', title: '奖品名称'},
                    {field: 'odds', title: '中奖概率', search: false, templet: function (d) {
                        return d.odds + '%';
                    }},
                    {field: 'actual_odds', title: '真实中奖率', search: false, templet: function (d) {
                        return d.actual_odds + '%';
                    }},
                    {field: 'stock', title: '库存数量', search: false},
                    {field: 'price', title: '价格', search: false},
                    {field: 'create_time', title: '创建时间', search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});